#version 330 core

out vec4 FragColor;

in vec3 Normal;
in vec3 FragPos;

uniform vec3 object_color;
uniform vec3 world_light_color;
uniform int object_type;
uniform vec3 light_pos;

void main() {
    if (object_type == 0) {
        FragColor = vec4(world_light_color, 1.0);
    } else {
        vec3 norm = normalize(Normal);
        vec3 lightDir = normalize(light_pos - FragPos);

        float diff = max(dot(norm, lightDir), 0.0);

        vec3 am_color = vec3(world_light_color * object_color) * 0.2;
        vec3 diff_color = diff * world_light_color;

        vec3 result = (am_color + diff_color) * object_color;
        FragColor = vec4(result, 1.0);
    }
}
